﻿package mortal.game.view.signUp.sevenDayLogin.panel
{
    import com.mui.controls.*;
    import com.mui.core.*;
    import mortal.component.gconst.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.signUp.sevenDayLogin.data.*;

    public class SevenDayOneCell extends GSprite
    {
        protected var _bg:GBitmap;
        protected var _btnCk:GButton;
        protected var _gift:GBitmap;
        protected var _hasGotFlag:GBitmap;
        protected var _addNum:BitmapNumberText;
        private var _status:int = 2;
        private static var showAddNum:Object = {3:true, 7:true};

        public function SevenDayOneCell()
        {
            this.mouseEnabled = true;
            this.buttonMode = true;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.gBitmap(ImagesConst.SevenDayGiftBg, 0, 0, this);
            this._btnCk = UIFactory.gButton("", 19, 14, 57, 57, this);
            this._gift = UIFactory.gBitmap(ImagesConst.SevenDayGift, 19, 12, this);
            this._hasGotFlag = UIFactory.gBitmap(ImagesConst.SevenDayLoginHasGetFlag, 11, 56, this);
            this._addNum = UIFactory.bitmapNumberText(36, 57, "EquipmentTipsNumber.png", 16, 16, -6, this, 13, 0);
            this._addNum.text = "";
            this._btnCk.alpha = 0.01;
            this._hasGotFlag.visible = false;
            this._addNum.mouseEnabled = false;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._hasGotFlag.visible = true;
            this._btnCk.alpha = 1;
            this._bg.dispose(param1);
            this._btnCk.dispose(param1);
            this._gift.dispose(param1);
            this._hasGotFlag.dispose(param1);
            this._bg = null;
            this._btnCk = null;
            this._gift = null;
            this._hasGotFlag = null;
            this._addNum = null;
            this._status = -1;
            return;
        }// end function

        public function updateStaues(param1:Object) : void
        {
            this._status = int(param1);
            this._gift.filters = null;
            EffectManager.glowFilterUnReg(this._bg);
            switch(this._status)
            {
                case ESevenDayStatus.canGet:
                {
                    EffectManager.glowFilterReg(this._bg, [FilterConst.chatTipsFilter], 0.6, 20, 2, 0);
                    break;
                }
                case ESevenDayStatus.canNotGet:
                {
                    break;
                }
                case ESevenDayStatus.hasGet:
                {
                    this._hasGotFlag.visible = true;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function updateDay(param1:int) : void
        {
            this._gift.bitmapData = GlobalClass.getBitmapData(ImagesConst["SevenDayGiftPic" + param1]);
            if (showAddNum[param1] && this._addNum)
            {
                this._addNum.text = "+3";
                this.addChild(this._addNum);
            }
            return;
        }// end function

        public function setSelect(param1:Boolean) : void
        {
            switch(this._status)
            {
                case ESevenDayStatus.canGet:
                {
                    break;
                }
                case ESevenDayStatus.canNotGet:
                case ESevenDayStatus.hasGet:
                {
                    if (param1)
                    {
                        this._bg.filters = [FilterConst.chatTipsFilter];
                    }
                    else
                    {
                        this._bg.filters = null;
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
